import http from '../../utils/http'
import type {ApiResponse, PageResult} from '../../utils/ApiResponse'
import {Feedback, PageFeedback} from "./types/feedback.dto.ts";

export const addFeedback = (data: Feedback): Promise<ApiResponse<Object>> => {
    return http.post('/feedbackInfo/save', data)
}

export const deleteFeedbackById = (id:number): Promise<ApiResponse<Object>> => {
    return http.delete(`/feedbackInfo/delete/${id}`)
}

export const saveFeedbackInfo = (data: Feedback): Promise<ApiResponse<Object>> => {
    return http.put('/feedbackInfo/save', data)
}

export const getAllFeedbacks = (data: PageFeedback): Promise<PageResult<Object>> => {
    return http.get('/feedbackInfo/info', {
        params: {
            page: data.page,
            limit: data.limit,
            feedbackType: data.feedbackType,
            status: data.status
        }
    })
}

export const getFeedbackInfoById = (id: number): Promise<ApiResponse<Feedback>> => {
    return http.get(`/feedbackInfo/info/${id}`)
}